package com.yang.app.controller;

import java.io.UnsupportedEncodingException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.yang.app.entity.TbUser;
import com.yang.app.entity.User;
import com.yang.app.service.IUserService;
import com.yang.app.view.UserView;
@Controller
@Scope("prototype")
@RequestMapping(value = "/view")
public class TestViewController {
	
	@Resource
	private IUserService userService;
	
	@RequestMapping(method = RequestMethod.GET)
	public String getAllUser(ModelMap model){
		System.out.println("I'm  coming  ................");
		
		return "index";
		
	}
	
	
	@ResponseBody
	@RequestMapping(value="/testJson",method = RequestMethod.GET)
	public UserView  testJson(ModelMap model,HttpServletRequest request){
		UserView uv = new UserView();
		List<User> users = userService.getAllUser();
		uv.setDatas(users);
		return uv;
		
	}
	
}
